package com.ruoyi.service.impl;

import com.hundun.vision.api.common.PlainResult;
import com.hundun.vision.api.dto.FeatureTemplateDTO;
import com.hundun.vision.api.service.RPCFeatureTemplateService;
import com.ruoyi.common.utils.ResultUtils;
import com.ruoyi.service.FeatureTemplateService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author ：RuoChen
 * @date ：09:20 2021/6/24
 * @description：特征模板服务实现类
 */
@Slf4j
@Component
public class FeatureTemplateServiceImpl implements FeatureTemplateService {

    @DubboReference(timeout = 60000, retries = 0)
    private RPCFeatureTemplateService featureTemplateService;

    @Override
    public List<FeatureTemplateDTO> list() {
        log.info("list feature templates");
        PlainResult<List<FeatureTemplateDTO>> result = featureTemplateService.list();
        if (result.isSuccess()) {
            return result.getData();
        } else {
            ResultUtils.error(result.getMessage());
        }
        return null;
    }
}
